home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRNEND.C < prev    next >
Text File  |  1993-01-04  |  896b  |  39 lines

  1.  
  2. /*  File   : strnend.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 1 June 1984
  5.     Defines: strnend()
  6.  
  7.     strnend(src, len)
  8.     returns a pointer to just after the end of the string src, which is
  9.     terminated by a NUL character, or by exhaustion of the length bound
  10.     len.  That is, strnend(s,L)-s = strnlen(s,L).  s+strnlen(s,L) could
  11.     of course be used instead, but this is sometimes clearer.
  12.     Beware: the asm version works only if 0 <= len < 65535.
  13. */
  14.  
  15. #include "strings.h"
  16.  
  17. #if     VaxAsm
  18.  
  19. char *strnend(src, len)
  20.     char *src;
  21.     int len;
  22.     {
  23.         asm("locc $0,8(ap),*4(ap)");
  24.         asm("movl r1,r0");
  25.     }
  26.  
  27. #else  ~VaxAsm
  28.  
  29. char *strnend(src, len)
  30.     register char *src;
  31.     register int len;
  32.     {
  33.         while (--len >= 0 && *src) src++;
  34.         return src;
  35.     }
  36.  
  37. #endif  VaxAsm
  38.  
  39.